﻿using mvcForum.Core.Interfaces.Data;
using System;
using System.Linq.Expressions;


namespace mvcForum.Core.Specifications {

	public static class ForumSpecifications {

		public class SpecificCategoryNoParentForum : ISpecification<Forum> {
			private readonly Category category;

			public SpecificCategoryNoParentForum(Category category) {
				this.category = category;
			}

			public Expression<Func<Forum, Boolean>> IsSatisfied {
				get {
					return f => f.CategoryId == category.Id && f.ParentForum == null;
				}
			}
		}

		public class ById : ISpecification<Forum> {
			private readonly Int32 id;

			public ById(Int32 id) {
				this.id = id;
			}

			public Expression<Func<Forum, Boolean>> IsSatisfied {
				get {
					return f => f.Id == this.id;
				}
			}
		}
	}
}